<script>
import { reactive, ref, toRefs } from 'vue'
export default {
  name: 'Header',
  setup () {
    const tabBar = reactive({
      list: [
        {
          title: '首页',
          path: '/home'
        },
        {
          title: '新房',
          path: '/newroom'
        },
        {
          title: '二手房',
          path: ''
        },
        {
          title: '租房',
          path: ''
        },
        {
          title: '商业写字楼',
          path: ''
        },
        {
          title: '装修',
          path: ''
        },
        {
          title: '楼讯',
          path: ''
        },
        {
          title: '房价',
          path: '/chart'
        },
        {
          title: '问答',
          path: ''
        }
      ]
    })
    const isActive = ref(1)
    const change = (idx) => {
      isActive.value = idx
    }
    return {
      ...toRefs(tabBar),
      isActive,
      change
    }
  }
}
</script>
<template>
  <header class="header">
    <ul class="header_container">
      <li v-for="(item,idx) in list" :key="idx" @click="change(idx)">
        <router-link :to="item.path">
          <div :class="isActive===idx?'active':''">{{item.title}}</div>
        </router-link>
      </li>
    </ul>
  </header>
</template>

<style lang='less'>
.header {
  width: 100%;
  height: 36px;
  background: #333333;
  margin: 0 auto;
  .header_container {
    display: flex;
    align-items: center;
    width: 1180px;
    height: 100%;
    margin: 0 auto;
    li {
      margin-right: 24px;
      div {
        font-weight: 500;
        font-size: 12px;
        color: #9b9b9b;
      }
      .active {
        color: #fff !important;
      }
    }
  }
}
</style>
